package com.ld.control.business.xd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ld.control.business.task.service.TaskExampleService;
import com.ld.control.business.xd.mapper.XdBigScreenEquipmentMapper;
import com.ld.control.business.xd.model.XdBigScreenEquipmentModel;
import com.ld.control.business.xd.service.XdBigScreenEquipmentService;
import com.ld.control.business.xd.vo.resp.XdBigScreenEquipmentRespVo;
import com.ld.control.business.xd.vo.resp.xdTaskNumberRespVo;
import com.ld.control.common.vo.GenerateListVo;
import com.ld.control.sysenum.TaskStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * xd大屏定制 服务实现类
 * </p>
 *
 * @author wangfeng
 * @since 2025-10-12
 */
@Service
public class XdBigScreenEquipmentServiceImpl extends ServiceImpl<XdBigScreenEquipmentMapper, XdBigScreenEquipmentModel> implements XdBigScreenEquipmentService {

    @Autowired
    private XdBigScreenEquipmentMapper xdBigScreenEquipmentMapper;

    @Autowired
    private TaskExampleService taskExampleService;

    @Override
    public GenerateListVo<XdBigScreenEquipmentRespVo> selectAllList(Integer regionFlag) {
        List<XdBigScreenEquipmentRespVo> xdBigScreenEquipmentRespList = xdBigScreenEquipmentMapper.selectAllList(regionFlag);
        return new GenerateListVo<>(xdBigScreenEquipmentRespList);
    }

    @Override
    public xdTaskNumberRespVo getXdTaskNumber() {
        xdTaskNumberRespVo xdTaskNumberRespVo = new xdTaskNumberRespVo();
        Long successTaskNumber = taskExampleService.getTaskExampleCountByStatus(TaskStatusEnum.SUCCESS.getStatus());
        Long unfinishedTaskNumber = taskExampleService.getTaskExampleCountByStatus(TaskStatusEnum.READY.getStatus());
        xdTaskNumberRespVo.setTaskTotal(successTaskNumber + unfinishedTaskNumber);
        xdTaskNumberRespVo.setSuccessTaskNumber(successTaskNumber);
        xdTaskNumberRespVo.setUnfinishedTaskNumber(unfinishedTaskNumber);
        return xdTaskNumberRespVo;
    }
}
